<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8">
		<title>登录</title>
		<link rel="stylesheet" href="layui/css/layui.css"/>	
		<link rel="stylesheet" href="layui/css/modules/layer/default/layer.css" />
		<link rel="stylesheet" href="layui/login.css" />
	</head>
	<body>
		<div class="wrap">
        <img src="img/kb.jpg" class="imgStyle">
        <div class="loginForm">
            <form class="layui-form" action="/login"  method="post">
                <div class="logoHead">
                    <h2 style="margin-top: 15px;margin-left:30px;">人力资源管理系统</h2>
                </div>
                <div class="usernameWrapDiv">
                    <div class="usernameLabel">
                        <label>用户名:</label>
                    </div>
                    <div class="usernameDiv">
                        <i class="layui-icon layui-icon-username adminIcon"></i>
                        <input  class="layui-input adminInput" type="text" name="account" id="account" placeholder="输入用户名">
                    </div>
                </div>
                <div class="usernameWrapDiv">
                    <div class="usernameLabel">
                        <label>密码:</label>
                    </div>
                    <div class="passwordDiv">
                        <i class="layui-icon layui-icon-password adminIcon"></i>
                        <input  class="layui-input adminInput" type="password" name="password" id="password" placeholder="输入密码">
                    </div>
                </div>
               
                <div class="layui-form-item">
                    <div class="button">
                        <button  class="submit layui-btn layui-btn-primary" lay-submit  lay-filter="formDemo">登录</button>
                    
                    	<button type="reset" class="submit layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
            
         <!--    <div style="padding-top: 20px;padding-left: 30px;font-size: 10px;"><span th:text="${msg}"></span></div>  -->
        </div>
    </div>
    <script src="layui/layui.js"></script>
    <script type="text/javascript">
       layui.use(['jquery','form'],function(){
    	   var form=layui.form;
    	   var $=layui.jquery;
    	   form.on('submit(formDemo)',function(data){
    		   //alert("hah");
    		  $.ajax({
    			 url:"/login",
    			type:'post',
    			async:false,
    			data:data.field,
    			success:function(data){
    				if(data==0){
    				layer.msg("成功");
    				window.setTimeout(function(){window.location.href="/superIndex";},500)
    				}else if(data==1){
    					layer.msg("成功");
    					window.setTimeout(function(){window.location.href="/manaIndex";},500)
    				}else if(data==2){
    					layer.msg("成功");
    					window.setTimeout(function(){window.location.href="/userIndex";},500)
    				}else if(data==-1){
    					layer.msg("账号或密码不正确");
    					window.setTimeout(function(){window.location.href="login.html";},500)
    				}else if(data==-2){
    					layer.msg("用户不存在");
    					window.setTimeout(function(){window.location.href="login.html";},500)
    				}
    			},
    		   error:function(){
    			   layer.msg("失败");
    		   }
    		  });
    		  return false;
    	   });
       });
    </script>
</body>
	
</html>
